package net.lzzy.algorithm.algorlib;
/*
时间复杂度：平方阶（-O(n2)）
 */
public class ShellSort<T extends Comparable<? super T>>extends BaseSort<T>{
     ShellSort(T[] itmes) {
        super(itmes);
    }
    @Override
    //====================希尔排序方法===========================
    public void sort() {
        int increment=itmes.length;
            int in=increment/2;
        while (in>0){
            for (int i = in; i < itmes.length; i+=in) {
                int j = i - in;
                if (comare(itmes[i], itmes[j])) {
                    continue;
                }
                T temp = itmes[i];
                while (j >= 0 && comare(itmes[j], temp)) {
                    itmes[j + in] = itmes[j];
                    j-=in;
                }
                compareMove++;
                itmes[j + in] = temp;
            }
            in=in/2;
        }
    }
}
